<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h1>obj.a = {{obj.a}}</h1>
      <p>
        <button @click="$delete(obj, 'a')">delete a</button>
        <button @click="$set(obj, 'b', Math.random())">add b</button>
      </p>
      <ul>
        <li v-for="n in arr">{{n}}</li>
      </ul>
      <button @click="arr.sort(()=>Math.random()-0.5)">resort</button>
      <!-- <button @click="arr[0].name='莫妮卡'">change first</button> -->
      <button @click="k++">change k</button>
    </div>
    <script src="./vue.min.js"></script>
    <script>
      var vm = new Vue({
        el: "#app",
        data() {
          return {
            obj: { a: 1, c: 111 },
            arr: [1, 2, 3, 4],
            k: 3,
          };
        },
        mounted() {
          console.log(this);
        },
        render(h) {
          console.log("render");
          return h("div", [
            h("h1", `obj.a = ${this.obj.a}`),
            h(
              "button",
              {
                on: {
                  click: () => {
                    // this.$delete(this.obj, "c");
                    this.k++;
                  },
                },
              },
              "add b"
            ),
          ]);
        },
      });
    </script>
  </body>
</html>
